package com.auto.service.impl;

import java.io.File;
import java.io.IOException;
import com.common.Global;
import freemarker.template.Configuration;
import freemarker.template.TemplateExceptionHandler;
import org.apache.log4j.Logger;
import org.springframework.util.ClassUtils;

public class FMConfiguration {
	private static Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	static {
		try {
//			cfg.setDirectoryForTemplateLoading(new File(System.getProperty("user.dir")+Global.TEMPLATEPATH));
			cfg.setDirectoryForTemplateLoading(new File(ClassUtils.getDefaultClassLoader().getResource("").getPath()+Global.TEMPLATEPATH));
			//cfg.setDefaultEncoding("UTF-8");
			cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			cfg.setDefaultEncoding(Global.ENCODE);
		} catch (IOException e) {
			e.printStackTrace();
			Logger.getLogger(FMConfiguration.class).error(e.getMessage());
		}
	}
	private FMConfiguration() {
		
	}
	public static Configuration getInstance() throws IOException {
		return cfg;
	}

}
